package com.sqstudio.exercise.chapter3{
	
	import flash.events.Event;
	
	import org.papervision3d.objects.primitives.Sphere;
	import org.papervision3d.view.BasicView;
	
	[SWF(width="800",height="600")]
	public class NestingExample extends BasicView
	{
		private var parentSphere:Sphere;

		private var childSphere:Sphere;
		public function NestingExample(viewportWidth:Number=800, viewportHeight:Number=600, scaleToStage:Boolean=true, interactive:Boolean=false, cameraType:String="Target")
		{
			super(viewportWidth, viewportHeight, scaleToStage, interactive, cameraType);
			stage.frameRate = 40;
			init();
			this.startRendering();
		}
		
		private function init():void{
			this.parentSphere = new Sphere(null,200,16,12);
			scene.addChild(parentSphere);
			
			childSphere = new Sphere();
			childSphere.x = 400;
			this.parentSphere.addChild(childSphere);
		}
		
		override protected function onRenderTick(event:Event=null):void
		{
			trace(childSphere.sceneX);
			trace(parentSphere.sceneX);
			this.parentSphere.localRotationY ++;
			super.onRenderTick(event);
		}
	}
}